<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('审核房源信息')" />
    <th:block th:include="include :: select2-css" />
</head>
<style>
    .divImg {
        float: left;
        margin: 2px;
        padding: 2px;
        height: 108px;
        width: 100px;
        border: 1px solid #dcdcdc;
        cursor: pointer;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-house-edit" th:object="${house}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">名称：</label>
            <div class="col-sm-8">
                <input name="name" th:field="*{name}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red">*</span>轮播图</label>
            <div class="col-sm-8">
                <div style="text-align: left;">
                    <button type="button" class="layui-btn" id="upload_car_img0" >上传图片</button>
                </div>
                <div class="layui-upload-list">
                    <div id="img-url0" style="padding: 5px;"></div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">装修：</label>
            <div class="col-sm-8">
                <select name="renovationId" class="form-control m-b"  >
                    <option th:each="dict : ${renovationList}" th:text="${dict.name}" th:value="${dict.id}" th:field="*{renovationId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">类型：</label>
            <div class="col-sm-8">
                <select name="typeId" class="form-control m-b"  >
                    <option th:each="dict : ${typeList}" th:text="${dict.name}" th:value="${dict.id}" th:field="*{typeId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">朝向：</label>
            <div class="col-sm-8">
                <select name="orientationId" class="form-control m-b"  >
                    <option th:each="dict : ${orientationList}" th:text="${dict.name}" th:value="${dict.id}" th:field="*{orientationId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">年代：</label>
            <div class="col-sm-8">
                <input name="years" th:field="*{years}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址：</label>
            <div class="col-sm-8">
                <textarea name="address" class="form-control">[[*{address}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">
                <textarea name="notes" class="form-control">[[*{notes}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">售价(单位：万)：</label>
            <div class="col-sm-8">
                <input name="price" th:field="*{price}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">单价(单位：元)：</label>
            <div class="col-sm-8">
                <input name="priceOne" th:field="*{priceOne}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">户型-室：</label>
            <div class="col-sm-8">
                <input name="houseRoom" th:field="*{houseRoom}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">户型-厅：</label>
            <div class="col-sm-8">
                <input name="houseLivingRoom" th:field="*{houseLivingRoom}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">户型-卫：</label>
            <div class="col-sm-8">
                <input name="houseToilet" th:field="*{houseToilet}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">面积：</label>
            <div class="col-sm-8">
                <input name="area" th:field="*{area}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">楼层：</label>
            <div class="col-sm-8">
                <input name="floor" th:field="*{floor}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">总楼层：</label>
            <div class="col-sm-8">
                <input name="floorMax" th:field="*{floorMax}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">标签：</label>
            <div class="col-sm-8">
                <textarea name="tag" class="form-control">[[*{tag}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">排序：</label>
            <div class="col-sm-8">
                <input name="sort" th:field="*{sort}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box">
                    <input type="radio" id="status_0" name="status" value="0" th:field="*{status}">
                    <label for="status_0">待审核</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="status_1" name="status" value="1" th:field="*{status}" >
                    <label for="status_1">通过</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="status_2" name="status" value="2" th:field="*{status}">
                    <label for="status_2">不通过</label>
                </div>
            </div>
        </div>

        <div class="form-group" id="reason" th:style="'display:'+ @{(*{status}!=2? 'none':'block')}">
            <label class="col-sm-3 control-label">拒绝原因：</label>
            <div class="col-sm-8">
                <input name="reason" th:field="*{reason}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">独家房源：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('house_sole')}">
                    <input type="radio" th:id="${'sole_' + dict.dictCode}" name="sole" th:value="${dict.dictValue}" th:field="*{sole}">
                    <label th:for="${'sole_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否推荐：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('house_recommend')}">
                    <input type="radio" th:id="${'recommend_' + dict.dictCode}" name="isRecommend" th:value="${dict.dictValue}" th:field="*{isRecommend}">
                    <label th:for="${'recommend_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">类型：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('house_type')}">
                    <input type="radio" th:id="${'type_' + dict.dictCode}" name="type" th:value="${dict.dictValue}" th:field="*{type}">
                    <label th:for="${'type_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: sortable-js"/>
<script type="text/javascript" th:inline="javascript">
    var prefix = ctx + "system/house/house";
    $("#form-house-edit").validate({
        focusCleanup: true
    });

    var imgId0=0;
    if([[${house.houseImgs}]]!=undefined && [[${house.houseImgs}]]!=[]) {
        var houseImgs =[[${house.houseImgs}]];
        for (o in houseImgs) {
            imgId0++;
            $("#img-url0").append("<div id='imgId0" + imgId0 + "' class='divImg'>" +
                "<img src='" + houseImgs[o].url + "' style='width:100px;height: 80px;margin-bottom: 1px;'><br>" +
                "<input type='hidden' name='carImg0' value='" + houseImgs[o].url + "'>" +
                "<i style='float: right;padding-top: 4px;' class='fa fa-close' onclick=\"delImg('imgId0" + imgId0 + "')\"></i></div>");
            // $("#logo").val(res.url);
        }
    }


    function delImg(id) {
        $("#" + id).remove();
    }
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-house-edit').serialize());
        }
    }

    $("input[type=radio][name=status]").on("ifChecked", function () {
        //不通过
        if ($(this).val() == 2) {
            //展示原因
            $("#reason").show();
        } else {
            //隐藏原因
            $("#reason").hide();
        }
    });


</script>
</body>
</html>